package com.github.shiqiyue.learn.guava;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/***
 * BiMap 测试
 * @author wenyao.wu
 * @date 2018/7/2
 */
public class BiMapTest {

    private static final Logger logger = LoggerFactory.getLogger(BiMapTest.class);


    public static void main(String[] args) {
        /***
         * bimap 双向map,通过reverse方式翻转map,key变成value,value变成key
         */
        BiMap<Integer, String> empIDNameMap = HashBiMap.create();

        // 初始化数据
        empIDNameMap.put(new Integer(101), "Mahesh");
        empIDNameMap.put(new Integer(102), "Sohan");
        empIDNameMap.put(new Integer(103), "Ramesh");

        // 翻转map，获取值
        logger.info("emp id of employee[Mahesh]:{}", empIDNameMap.inverse().get("Ramesh"));
    }
}
